﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<CRM.Database.Model.Users>>" %>

<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdUsers";
                                        settings.KeyFieldName = "IdUser";
                                        settings.CallbackRouteValues =
                                            new { Controller = "Dictionaries", Action = "UsersPartial" };
                                        settings.SettingsPager.PageSize = 20;

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.UserFullNameEn;
                                            column.FieldName = "IdUser";
                                            // column.
                                            column.ColumnType = MVCxGridViewColumnType.HyperLink;
                                            column.Settings.FilterMode = ColumnFilterMode.DisplayText;
                                            column.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                                            HyperLinkProperties properties = column.PropertiesEdit as HyperLinkProperties;
                                            String urlFormatString = Url.Action("Details", "Users", new RouteValueDictionary(new { id = "{0}" }));

                                            properties.NavigateUrlFormatString = HttpUtility.UrlDecode(urlFormatString);
                                            properties.TextField = "UserFullNameEn";

                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.UserFullNameRu;
                                            column.FieldName = "IdUser";
                                            // column.
                                            column.ColumnType = MVCxGridViewColumnType.HyperLink;
                                            column.Settings.FilterMode = ColumnFilterMode.DisplayText;
                                            column.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                                            HyperLinkProperties properties = column.PropertiesEdit as HyperLinkProperties;
                                            String urlFormatString = Url.Action("Details", "Users", new RouteValueDictionary(new { id = "{0}" }));

                                            properties.NavigateUrlFormatString = HttpUtility.UrlDecode(urlFormatString);
                                            properties.TextField = "UserFullNameRu";

                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.UserEmail;
                                            column.FieldName = "UserEmail";
                                        });

                                        //settings.Columns.Add(column =>
                                        //{
                                        //    column.Caption = Resourses.UserFullNameRu;
                                        //    column.FieldName = "UserFullNameRu";
                                        //});

                                        //settings.Columns.Add(column =>
                                        //{
                                        //    column.Caption = Resourses.UserLogin;
                                        //    column.FieldName = "UserLogin";
                                        //});

                                       

                                        //
                                        //Добавление редактирования
                                        //
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = false;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = false;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dictionaries", Action = "UsersPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dictionaries", Action = "UsersPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dictionaries", Action = "UsersPartialDelete" };

                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);

                                        
                                    })
       .Bind(Model).GetHtml();
%>